<?php
/**
 * Created by PhpStorm.
 * User: 12133
 * Date: 2024/5/9
 * Time: 14:30
 */

namespace app\controller\admin;
use app\model\Classify AS model;

class Classify extends Base
{
    public function list(){
        $list = new model();
        $list = $list->paginate(['page' => $this->page,'list_rows' => $this->size]);
        return $this->view('/admin/ci/list',['list' => $list]);
    }

    public function info(){
        $id = input('id',0);
        $info = model::find($id);
        return $this->view('/admin/ci/info',['info' => $info ?? 0,'id' => $id ?? 0]);
    }

    public function save(){
        $id = input('id');
        $data = input('post.data');
        if (!empty($id)){
            $info = model::find($id);
            $info->save($data);
        }else{
            model::create($data);
        }
        return $this->msg();
    }

    public function delete($id){;
        $ids = input('ids');
        if (!empty($ids)){
            model::where('id','IN',$ids)->delete();
        }else {
            model::find($id)->delete();
        }
        return $this->msg();
    }
}